import request from '@/config/axios'

export interface EvalScoreRecordVO {
  id?: number
  planId: number
  subjectId: number
  candidateId: number
  evaluatorId: number
  scoreDetails?: string
  sectionScores?: string
  totalScore: number
  maxScore: number
  isPassed?: boolean
  scoreStatus: number
  scoreComments?: string
  evaluatorComments?: string
  isReviewed?: boolean
  reviewerId?: number
  reviewTime?: Date
  reviewComments?: string
  submitTime?: Date
  confirmTime?: Date
  createTime?: Date
}

export interface EvalScoreRecordPageReqVO extends PageParam {
  planId?: number
  subjectId?: number
  candidateId?: number
  evaluatorId?: number
  scoreStatus?: number
  isPassed?: boolean
  isReviewed?: boolean
  submitTime?: Date[]
  createTime?: Date[]
}

export interface EvalScoreSummaryVO {
  id?: number
  planId: number
  candidateId: number
  totalScore: number
  weightedScore: number
  isQualified: boolean
  gradeLevel?: string
  summaryStatus: number
  createTime?: Date
}

export interface EvalScoreSummaryPageReqVO extends PageParam {
  planId?: number
  candidateId?: number
  isQualified?: boolean
  gradeLevel?: string
  summaryStatus?: number
  createTime?: Date[]
}

export interface EvalScoreBatchCreateReqVO {
  scoreRecords: EvalScoreRecordVO[]
}

// 查询评分记录分页
export const getScoreRecordPage = (params: EvalScoreRecordPageReqVO) => {
  return request.get({ url: '/eval/score-record/page', params })
}

// 查询评分记录详情
export const getScoreRecord = (id: number) => {
  return request.get({ url: '/eval/score-record/get?id=' + id })
}

// 新增评分记录
export const createScoreRecord = (data: EvalScoreRecordVO) => {
  return request.post({ url: '/eval/score-record/create', data })
}

// 修改评分记录
export const updateScoreRecord = (data: EvalScoreRecordVO) => {
  return request.put({ url: '/eval/score-record/update', data })
}

// 删除评分记录
export const deleteScoreRecord = (id: number) => {
  return request.delete({ url: '/eval/score-record/delete?id=' + id })
}

// 导出评分记录
export const exportScoreRecord = (params: EvalScoreRecordPageReqVO) => {
  return request.download({ url: '/eval/score-record/export-excel', params })
}

// 批量创建评分记录
export const batchCreateScoreRecords = (data: EvalScoreBatchCreateReqVO) => {
  return request.post({ url: '/eval/score-record/batch-create', data })
}

// 根据计划ID和科目ID获得评分记录列表
export const getScoreRecordListByPlanAndSubject = (planId: number, subjectId: number) => {
  return request.get({ url: `/eval/score-record/list-by-plan-and-subject?planId=${planId}&subjectId=${subjectId}` })
}

// 查询成绩汇总分页
export const getScoreSummaryPage = (params: EvalScoreSummaryPageReqVO) => {
  return request.get({ url: '/eval/score-summary/page', params })
}

// 查询成绩汇总详情
export const getScoreSummary = (id: number) => {
  return request.get({ url: '/eval/score-summary/get?id=' + id })
}

// 新增成绩汇总
export const createScoreSummary = (data: EvalScoreSummaryVO) => {
  return request.post({ url: '/eval/score-summary/create', data })
}

// 修改成绩汇总
export const updateScoreSummary = (data: EvalScoreSummaryVO) => {
  return request.put({ url: '/eval/score-summary/update', data })
}

// 删除成绩汇总
export const deleteScoreSummary = (id: number) => {
  return request.delete({ url: '/eval/score-summary/delete?id=' + id })
}

// 导出成绩汇总
export const exportScoreSummary = (params: EvalScoreSummaryPageReqVO) => {
  return request.download({ url: '/eval/score-summary/export-excel', params })
}

// 根据计划ID获得成绩汇总列表
export const getScoreSummaryListByPlanId = (planId: number) => {
  return request.get({ url: '/eval/score-summary/list-by-plan?planId=' + planId })
}

// 计算成绩汇总
export const calculateScoreSummary = (planId: number) => {
  return request.post({ url: '/eval/score-summary/calculate?planId=' + planId })
}

// 批量计算成绩汇总
export const batchCalculateScoreSummary = (planIds: number[]) => {
  return request.post({ url: '/eval/score-summary/batch-calculate', data: { planIds } })
}
